package com.itheima.file;


import java.io.*;

public class UserIODemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        User u1=new User("小强","23");
        User u2=new User("大强","28");
        User u3=new User("强大","26");

        ObjectOutputStream  oos=new ObjectOutputStream(new FileOutputStream("c.txt"));
        oos.writeObject(u1);
        oos.writeObject(u2);
        oos.writeObject(u3);
        oos.close();

        ObjectInputStream  ois=new ObjectInputStream(new FileInputStream("c.txt"));
        while (true){
            try {
                User u = (User)ois.readObject();
                System.out.println(u);
            } catch (IOException e) {
             break;
            }
        }
        ois.close();
    }
}
